﻿<!-- Views/Admin/DeleteQuestion.cshtml -->
@model WebApplication1.Models.Question

@{
    ViewBag.Title = WebApplication1.Utilities.LanguageManager.GetText("DeleteQuestion");
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card shadow-sm">
                <div class="card-header @(ViewBag.HasUserAnswers == true || ViewBag.HasPracticeAnswers == true ? "bg-warning" : "bg-danger") text-white">
                    <h5 class="mb-0">
                        <i class="glyphicon glyphicon-trash"></i>
                        @(ViewBag.HasUserAnswers == true || ViewBag.HasPracticeAnswers == true ?
                            WebApplication1.Utilities.LanguageManager.GetText("CannotDeleteQuestion") :
                            WebApplication1.Utilities.LanguageManager.GetText("DeleteQuestion"))
                    </h5>
                </div>
                <div class="card-body">
                    @if (ViewBag.HasUserAnswers == true || ViewBag.HasPracticeAnswers == true)
                    {
                        <div class="alert alert-warning">
                            <h4 class="alert-heading">
                                <i class="glyphicon glyphicon-info-sign"></i>
                                @ViewBag.CannotDeleteQuestion
                            </h4>
                            <p>@WebApplication1.Utilities.LanguageManager.GetText("QuestionDeleteInfo")</p>
                            @if (ViewBag.HasUserAnswers == true)
                            {
                                <p><i class="glyphicon glyphicon-list-alt text-warning"></i> @ViewBag.QuestionHasUserAnswers</p>
                            }
                            @if (ViewBag.HasPracticeAnswers == true)
                            {
                                <p><i class="glyphicon glyphicon-education text-warning"></i> @ViewBag.QuestionHasPracticeAnswers</p>
                            }
                            <div class="mt-3">
                                <div class="alert alert-info">
                                    <i class="glyphicon glyphicon-info-sign"></i>
                                    <strong>@WebApplication1.Utilities.LanguageManager.GetText("Info"):</strong>
                                    @WebApplication1.Utilities.LanguageManager.GetText("QuestionWillBeMarkedAsDeleted")
                                </div>
                            </div>
                        </div>
                    }
                    else
                    {
                        <div class="alert alert-danger">
                            <h4 class="alert-heading">
                                <i class="glyphicon glyphicon-exclamation-sign"></i>
                                @ViewBag.ConfirmDeleteQuestion
                            </h4>
                            <p>@WebApplication1.Utilities.LanguageManager.GetText("DeleteQuestionWarningMessage")</p>
                        </div>
                    }

                    <div class="row mb-4">
                        <div class="col-md-8">
                            <div class="card border-info">
                                <div class="card-header bg-info text-white">
                                    <h6 class="mb-0">@WebApplication1.Utilities.LanguageManager.GetText("QuestionInfo")</h6>
                                </div>
                                <div class="card-body">
                                    <dl class="row">
                                        <dt class="col-sm-3">@ViewBag.ExamName:</dt>
                                        <dd class="col-sm-9">
                                            <strong>@Model.Exam.ExamName</strong>
                                        </dd>

                                        <dt class="col-sm-3">@ViewBag.QuestionContent:</dt>
                                        <dd class="col-sm-9">
                                            @Model.QuestionText
                                        </dd>

                                        <dt class="col-sm-3">@ViewBag.QuestionType:</dt>
                                        <dd class="col-sm-9">
                                            @if (Model.QuestionType == "Single")
                                            {
                                                <span class="badge bg-primary">@WebApplication1.Utilities.LanguageManager.GetText("SingleChoice")</span>
                                            }
                                            else if (Model.QuestionType == "Multiple")
                                            {
                                                <span class="badge bg-success">@WebApplication1.Utilities.LanguageManager.GetText("MultipleChoice")</span>
                                            }
                                            else if (Model.QuestionType == "TrueFalse")
                                            {
                                                <span class="badge bg-info">@WebApplication1.Utilities.LanguageManager.GetText("TrueFalse")</span>
                                            }
                                            else if (Model.QuestionType == "Fill")
                                            {
                                                <span class="badge bg-warning">@WebApplication1.Utilities.LanguageManager.GetText("FillBlank")</span>
                                            }
                                        </dd>

                                        <dt class="col-sm-3">@ViewBag.Score:</dt>
                                        <dd class="col-sm-9">
                                            <span class="badge bg-success">@Model.Score @WebApplication1.Utilities.LanguageManager.GetText("Score")</span>
                                        </dd>

                                        <dt class="col-sm-3">@WebApplication1.Utilities.LanguageManager.GetText("CorrectAnswer"):</dt>
                                        <dd class="col-sm-9">
                                            <code>@Model.CorrectAnswer</code>
                                        </dd>
                                    </dl>
                                </div>
                            </div>
                        </div>
                    </div>

                    @using (Html.BeginForm())
                    {
                        @Html.AntiForgeryToken()
                        @Html.HiddenFor(model => model.QuestionId)

                        <div class="form-group">
                            <button type="submit" class="btn btn-@(ViewBag.HasUserAnswers == true || ViewBag.HasPracticeAnswers == true ? "warning" : "danger") btn-lg"
                                    onclick="return confirm('@WebApplication1.Utilities.LanguageManager.GetText("ConfirmDeleteQuestionMessage")')">
                                <i class="glyphicon glyphicon-trash"></i>
                                @(ViewBag.HasUserAnswers == true || ViewBag.HasPracticeAnswers == true ?
                                    WebApplication1.Utilities.LanguageManager.GetText("MarkAsDeleted") :
                                    ViewBag.ConfirmDelete)
                            </button>
                            <a href="@Url.Action("Questions", "Admin", new { examId = ViewBag.ExamId })" class="btn btn-secondary btn-lg">
                                <i class="glyphicon glyphicon-arrow-left"></i>
                                @ViewBag.Cancel
                            </a>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .card {
        border-radius: 10px;
    }

    .card-header {
        border-radius: 10px 10px 0 0 !important;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1.1rem;
        margin-right: 10px;
    }

    .alert-warning, .alert-danger {
        border-radius: 8px;
    }

    dl.row dt {
        font-weight: 600;
    }

    .badge {
        font-size: 0.95rem;
    }

    .alert p {
        margin-bottom: 0.5rem;
    }

    .alert-info {
        border-radius: 5px;
        font-size: 0.9rem;
    }
</style>
<script src="~/Scripts/jquery-3.6.0.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>

<script>
    $(document).ready(function() {
        // 确保确认对话框显示正确
        $('form').submit(function() {
            return confirm('@WebApplication1.Utilities.LanguageManager.GetText("ConfirmDeleteQuestionMessage")');
        });
    });
</script>